
#include<iostream>
#include"serve.hpp"
#include"dictionary.hpp"
//#include"Log.hpp"



using task_t = std::function<void()>;
// serve _port

std::string defaulthandler(const std::string& word)
{
    return "hhh"+word+"\n";
}
int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        LOG(LogLevel::ERROR)<<"serve port";
        exit(EXIT_EER);
    }
    //route-
    uint16_t port=stoi(argv[1]);
    //pthread
    //auto pth=Pthreadpool<task_t>::GetIncestance();
    // TCP_serve tcp(port);
    // tcp.Init();
    // tcp.Start();
    //makeunique
    dict dict;
    dict.Loaddict();
    std::unique_ptr<TCP_serve> tsvr=std::make_unique<TCP_serve>(port,[&dict](const std::string& word,InetAddr addr){
        return dict.Translate(word,addr);
    });
    tsvr->Init();
    tsvr->Start();
    //     bind();
    // }) 
    return 0;
}
